home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10372 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Standard question - pointer initialization
  5. Date: 13 Mar 96 22:45:37 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.826757137@rscernix>
  8. References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl> <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com> <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com> <4i7cve$5da@baygull.rtd.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4i7cve$5da@baygull.rtd.com> collins@RTD.COM (Ronald Collins) writes:
  13.  
  14. >Ronald Collins (collins@RTD.COM) wrote:
  15. >: Kazimir Kylheku (c2a192@ugrad.cs.ubc.ca) wrote:
  16. >
  17. >: : Also note that NULL is just a macro that stands for the value zero (often
  18. >: : accompanied by a cast to void *). In assigning default initialization values to
  19. >: : static variables, the compiler couldn't care less that there is a pre-processor
  20. >: : macro called NULL. NULL can never be anything other than zero in a
  21. >: : standard-conforming implementation of the C language.
  22. >
  23. >: This may be true on _your_ implementation, but nothing in the standard
  24. >: requires the NULL value to be numerically 0.
  25. >
  26. >: Please read the FAQ before posting on the subject again.
  27. >
  28. >To follow-up on my own post ... the standard requires a zero to be
  29. >used as NULL _only_ when the literal "0" is used. 
  30.  
  31. You're still wrong.  Any integral constant expression evaluating to 0
  32. will do the job.
  33.  
  34. >A variable set to
  35. >0 (as in "int var = 0;") then cast to a pointer (as in "*p = (char *) var")
  36. >is _not_ required to convert to a NULL.
  37.  
  38. True, but completely irrelevant.  Kazimir was talking about the definition
  39. of the NULL macro and the way static variables are initialized.  There's
  40. no place for variables in this context.
  41.  
  42. >If, above, you were talking about a literal "0", then I withdraw my comments.
  43. >If you were talking of any numeric 0 value casting to a NULL, then my
  44. >comments stand.                            ^^^^^^^^^^^^^^^^^
  45.  
  46. I can't parse "casting to a NULL".  AFAIK, you can cast to a type, not
  47. to a macro.
  48.  
  49. I'm afraid your comments are completely out of context.  Try to avoid
  50. spreading confusion on a very clear topic.
  51.  
  52. Dan
  53. --
  54. Dan Pop
  55. CERN, CN Division
  56. Email: danpop@mail.cern.ch 
  57. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  58.